// Author: Domien Nowicki

#ifndef CELLSIDEWIDGET_H
#define CELLSIDEWIDGET_H

#include <QGraphicsItem>
#include "Pixel.h"
#include "Cell.h"

class CellSideWidget: public QObject, public QGraphicsItem
{
	Q_OBJECT 
public:
	CellSideWidget(Cell::Side side, QObject *parent=0);
	virtual ~CellSideWidget();

	void SetSideColor(const Pixel& color);
	const Pixel& GetSideColor() const;

	Cell::Side GetSide() const;

protected:
	QRectF boundingRect() const;
	QPainterPath shape() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void hoverEnterEvent(QGraphicsSceneHoverEvent *e);
	void hoverLeaveEvent(QGraphicsSceneHoverEvent *e);
	void mousePressEvent(QGraphicsSceneMouseEvent *e);
	void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
	void hoverMoveEvent(QGraphicsSceneHoverEvent *e);
signals:
	void clicked(CellSideWidget*);
private:
	void SetupPath();

	bool highlight;
	QPainterPath path;
	Cell::Side side;
	Pixel sideColor;
	QRectF bounds;




	static const unsigned int ITEMSIZE = 64, SIDEWIDTH = 15;
	static const unsigned int ITEMZ = 6;
};

#endif // CELLSIDEWIDGET_H
